<template>
  <div>
    <div id="slider" class="mui-slider">
      <div
        id="sliderSegmentedControl"
        class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted"
      >
        <ul class="mui-scroll">
          <li v-for="item in title" :key="item.title" @click="getimages(item.id)">{{item.title}}</li>
        </ul>
      </div>
    </div>
    <ul class="imgs">
      <li v-for="item in imgs" :key="item.id" @click="getinfo(item.id)"><img :src="item.img_url" :title="item.title"><div><h4>{{item.title}}</h4><p>{{item.zhaiyao}}</p></div></li>
    </ul>
  </div>
</template>

<script>
import { getimgcategory,getimages,getimageInfo } from "@/api";
import mui from "@/lib/mui/js/mui.min.js";

export default {
  data() {
    return {
      title: [''],
      imgs: []
    };
  },
  methods: {
    getinfo(id){
      console.log(this.$router.push)
      this.$router.push({name:'photoinfo',params: { id: id }})
      console.log(123)
    },
    getimg() {
      getimgcategory().then(res => {
        this.title = res.data.message;
        this.title.unshift({ title: "全部", id: 0 });
      });
    },
    getimages(id){
      getimages(id).then(res=>{
        console.log(res)
        this.imgs = res.data.message
      })
    }
  },
  created() {
    this.getimages(0),
    this.getimg();
  },
  mounted() {
    mui(".mui-scroll-wrapper").scroll({
      deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    });
    
  }
};
</script>

<style lang="less" scoped>
* {
  touch-action: pan-y;
}
.mui-scroll-wrapper {
  width: 100%;
  overflow: hidden;
  .mui-scroll {
    width: 700px;
    margin: 5px 0;
    padding: 0;
    list-style: none;
    li {
      float: left;
      padding: 5px;
    }
  }
}
.imgs{
  margin-top: 10px;
  li{
    margin: 10px;
    position: relative;
    box-shadow: 0 0 9px #000;
    overflow: hidden;
    img{
      width: 100%;
      height: 100%;
      display: block;
    }
    div{
      background-color: rgba(0,0,0,.4);
      max-height: 40%;
      position: absolute;
      left: 0;
      bottom: 0;
      color: #fff;
      p{
        color: #fff;
      }
    }
  }
}
</style>
